package org.mozhu.zufang.system.privilege.repository;

import org.mozhu.mboot.core.data.BaseRepository;
import org.mozhu.zufang.system.privilege.entity.Permission;
import org.springframework.data.jpa.repository.Query;

import java.util.Collection;
import java.util.List;

/**
 * 权限 - 数据访问层接口
 * 
 * @author mozhu
 */
public interface PermissionRepository extends BaseRepository<Permission, Long> {

	@Query("select id from Permission where defaultPermission=true and show=true")
	List<Long> findDefaultPermissionIds();

	@Query("from Permission where defaultPermission=true and show=true")
	List<Permission> findDefaultPermissions();
	
	@Query("from Permission where show=true and id in (?1)")
	List<Permission> findAvailablePermissions(Collection<Long> permissionIds);
}
